package com.acwing.partition4;

import java.io.*;

/**
 * @author `RKC`
 * @date 2021/12/23 14:39
 */
public class AC323战略游戏 {

    private static final int N = 1510;
    private static int[] head = new int[N];
    private static int[][] element = new int[N][2], dp = new int[N][2];
    private static boolean[] notRoot = new boolean[N];
    private static int index = 0;

    private static final BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
    private static final BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(System.out));

    public static void main(String[] args) throws IOException {
        while (true) {
            String s = reader.readLine();
            if (s == null || s.isEmpty()) break;
            int n = Integer.parseInt(s), root = 0;
            for (int i = 0; i < n; i++) {
                head[i] = -1;
                notRoot[i] = false;
            }
            index = 0;
            for (int k = 0; k < n; k++) {
                s = reader.readLine();
                int h = Integer.parseInt(s.substring(0, s.indexOf(":"))), m = Integer.parseInt(s.substring(s.indexOf("(") + 1, s.indexOf(")")));
                String[] arr = s.split("\\s+");
                for (int i = 1; i <= m && i < arr.length; i++) {
                    int v = Integer.parseInt(arr[i]);
                    createEdge(h, v);
                    notRoot[v] = true;
                }
            }
            for (int i = 0; i < n; i++) {
                if (!notRoot[i]) {
                    root = i;
                    break;
                }
            }
            dfs(root);
            writer.write(Math.min(dp[root][0], dp[root][1]) + "\n");
        }
        writer.flush();
    }

    private static void dfs(int u) {
        dp[u][0] = 0;
        dp[u][1] = 1;
        for (int i = head[u]; i != -1; i = element[i][1]) {
            int v = element[i][0];
            dfs(v);
            dp[u][0] += dp[v][1];
            dp[u][1] += Math.min(dp[v][0], dp[v][1]);
        }
    }

    private static void createEdge(int u, int v) {
        int[] curr = element[index];
        curr[0] = v;
        curr[1] = head[u];
        head[u] = index++;
    }
}
